<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="keywords" content="Hexo Theme Redefine">
    
    <meta name="author" content="liyuncong">
    <!-- preconnect -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

    
    <!--- Seo Part-->
    
    <link rel="canonical" href="https://liyuncc.gitee.io/2024/01/09/data-check-code/"/>
    <meta name="robots" content="index,follow">
    <meta name="googlebot" content="index,follow">
    <meta name="revisit-after" content="1 days">
    
        <meta name="description" content="零、基本原理1、数据校验的基本原理 数据校验的基本原理是在正常编码中加入一些冗余位，即在正常编码组中加入一些非法编码，当合法数据编码出现某些错误时，就成为非法编码，因此就可以通过检测编码是否合法来达到自动发现、定位乃至改正错误的目的。   2、码距 通常把一组编码中任何两个编码之间代码不同的位数称为这两个编码的距离。而码距是指在一组编码中任何两个编码之间最小的距离。  解释： 同一编码中，任意两个">
<meta property="og:type" content="article">
<meta property="og:title" content="数据校验码">
<meta property="og:url" content="https://liyuncc.gitee.io/2024/01/09/data-check-code/index.html">
<meta property="og:site_name" content="YunCong&#39;s Blog">
<meta property="og:description" content="零、基本原理1、数据校验的基本原理 数据校验的基本原理是在正常编码中加入一些冗余位，即在正常编码组中加入一些非法编码，当合法数据编码出现某些错误时，就成为非法编码，因此就可以通过检测编码是否合法来达到自动发现、定位乃至改正错误的目的。   2、码距 通常把一组编码中任何两个编码之间代码不同的位数称为这两个编码的距离。而码距是指在一组编码中任何两个编码之间最小的距离。  解释： 同一编码中，任意两个">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="https://liyuncc.gitee.io/images/data-check-code-principle.png">
<meta property="og:image" content="https://liyuncc.gitee.io/images/data-check-principle-code-distances-and-correction-capability.png">
<meta property="og:image" content="https://liyuncc.gitee.io/images/data-check-code-parity-check.png">
<meta property="og:image" content="https://liyuncc.gitee.io/images/data-check-code-crc.png">
<meta property="og:image" content="https://liyuncc.gitee.io/images/data-check-code-crc-calculate-sender.png">
<meta property="og:image" content="https://liyuncc.gitee.io/images/data-check-code-crc-calculate-receiver.png">
<meta property="og:image" content="https://liyuncc.gitee.io/images/data-check-code-hamming-code.png">
<meta property="og:image" content="https://liyuncc.gitee.io/images/data-check-code-hamming-code-structure.png">
<meta property="og:image" content="https://liyuncc.gitee.io/images/data-check-code-hamming-code-check-mode.png">
<meta property="article:published_time" content="2024-01-09T09:25:32.000Z">
<meta property="article:modified_time" content="2024-01-10T02:47:40.469Z">
<meta property="article:author" content="liyuncong">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://liyuncc.gitee.io/images/data-check-code-principle.png">
    
    
    <!--- Icon Part-->
    <link rel="icon" type="image/png" href="/images/redefine-favicon.svg" sizes="192x192">
    <link rel="apple-touch-icon" sizes="180x180" href="/images/redefine-favicon.svg">
    <meta name="theme-color" content="#A31F34">
    <link rel="shortcut icon" href="/images/redefine-favicon.svg">
    <!--- Page Info-->
    
    <title>
        
            数据校验码 -
        
        YunCong&#39;s Blog
    </title>

    
<link rel="stylesheet" href="/fonts/Chillax/chillax.css">


    
        <style>
    :root {
        --preloader-background-color: #fff;
        --preloader-text-color: #000;
    }

    @media (prefers-color-scheme: dark) {
        :root {
            --preloader-background-color: #202124;
            --preloader-text-color: #fff;
        }
    }

    @media (prefers-color-scheme: light) {
        :root {
            --preloader-background-color: #fff;
            --preloader-text-color: #000;
        }
    }

    @media (max-width: 600px) {
        .ml13 {
            font-size: 2.6rem !important; /* Adjust this value as needed */
        }
    }

    .preloader {
        display: flex;
        flex-direction: column;
        gap: 1rem; /* Tailwind 'gap-4' is 1rem */
        align-items: center;
        justify-content: center;
        position: fixed;
        padding: 12px;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: 100vh; /* 'h-screen' is 100% of the viewport height */
        background-color: var(--preloader-background-color);
        z-index: 1100; /* 'z-[1100]' sets the z-index */
        transition: opacity 0.2s ease-in-out;
    }

    .ml13 {
        font-size: 3.2rem;
        /* text-transform: uppercase; */
        color: var(--preloader-text-color);
        letter-spacing: -1px;
        font-weight: 500;
        font-family: 'Chillax-Variable', sans-serif;
        text-align: center;
    }

    .ml13 .word {
        display: inline-flex;
        flex-wrap: wrap;
        white-space: nowrap;
    }

    .ml13 .letter {
        display: inline-block;
        line-height: 1em;
    }
</style>

<div class="preloader">
    
<script src="/js/libs/anime.min.js"></script>

    <h1 class="ml13">
        YunCong&#39;s Blog
    </h1>
    <script>
        var textWrapper = document.querySelector('.ml13');
        // Split text into words
        var words = textWrapper.textContent.trim().split(' ');

        // Clear the existing content
        textWrapper.innerHTML = '';

        // Wrap each word and its letters in spans
        words.forEach(function(word) {
            var wordSpan = document.createElement('span');
            wordSpan.classList.add('word');
            wordSpan.innerHTML = word.replace(/\S/g, "<span class='letter'>$&</span>");
            textWrapper.appendChild(wordSpan);
            textWrapper.appendChild(document.createTextNode(' ')); // Add space between words
        });


        anime.timeline({loop: true})
            .add({
                targets: '.ml13 .letter',
                translateY: [100,0],
                translateZ: 0,
                opacity: [0,1],
                easing: "easeOutExpo",
                duration: 1400,
                delay: (el, i) => 300 + 30 * i
            }).add({
            targets: '.ml13 .letter',
            translateY: [0,-100],
            opacity: [1,0],
            easing: "easeInExpo",
            duration: 1200,
            delay: (el, i) => 100 + 30 * i
        });

        let themeStatus = JSON.parse(localStorage.getItem('REDEFINE-THEME-STATUS'))?.isDark;

        // If the theme status is not found in local storage, check the preferred color scheme
        if (themeStatus === undefined || themeStatus === null) {
            if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
                themeStatus = 'dark';
            } else {
                themeStatus = 'light';
            }
        }

        // Now you can use the themeStatus variable in your code
        if (themeStatus) {
            document.documentElement.style.setProperty('--preloader-background-color', '#202124');
            document.documentElement.style.setProperty('--preloader-text-color', '#fff');
        } else {
            document.documentElement.style.setProperty('--preloader-background-color', '#fff');
            document.documentElement.style.setProperty('--preloader-text-color', '#000');
        }

        window.addEventListener('load', function () {
            hidePreloaderAfterTimeout(1000); // Hide after 1000 milliseconds once the window has loaded
        });

        // Backup failsafe: Hide preloader after a maximum of 5000 milliseconds, regardless of the window load event
        hidePreloaderAfterTimeout(5000);

        function hidePreloaderAfterTimeout(delay) {
            setTimeout(function () {
                var preloader = document.querySelector('.preloader');
                preloader.style.opacity = '0';
                setTimeout(function () {
                    preloader.style.display = 'none';
                }, 200);
            }, delay);
        }
    </script>
</div>
    

    
<link rel="stylesheet" href="/css/style.css">


    
        
<link rel="stylesheet" href="/assets/build/styles.css">

    

    
<link rel="stylesheet" href="/fonts/fonts.css">

    
<link rel="stylesheet" href="/fonts/Satoshi/satoshi.css">

    <!--- Font Part-->
    
    
    
    

    <!--- Inject Part-->
    
    <script id="hexo-configurations">
    window.config = {"hostname":"liyuncc.gitee.io","root":"/","language":"en"};
    window.theme = {"articles":{"style":{"font_size":"16px","line_height":1.5,"image_border_radius":"14px","image_alignment":"center","image_caption":false,"link_icon":true,"title_alignment":"left"},"word_count":{"enable":true,"count":true,"min2read":true},"author_label":{"enable":true,"auto":false,"list":[]},"code_block":{"copy":true,"style":"mac","font":{"enable":false,"family":null,"url":null}},"toc":{"enable":true,"max_depth":3,"number":false,"expand":true,"init_open":true},"copyright":{"enable":true,"default":"cc_by_nc_sa"},"lazyload":true,"recommendation":{"enable":false,"title":"推荐阅读","limit":3,"mobile_limit":2,"placeholder":"/images/wallhaven-wqery6-light.webp","skip_dirs":[]}},"colors":{"primary":"#A31F34","secondary":null},"global":{"fonts":{"chinese":{"enable":false,"family":null,"url":null},"english":{"enable":false,"family":null,"url":null}},"content_max_width":"1000px","sidebar_width":"210px","hover":{"shadow":true,"scale":false},"scroll_progress":{"bar":false,"percentage":true},"website_counter":{"url":"https://cn.vercount.one/js","enable":true,"site_pv":true,"site_uv":true,"post_pv":true},"single_page":true,"preloader":true,"open_graph":true,"google_analytics":{"enable":false,"id":null}},"home_banner":{"enable":true,"style":"fixed","image":{"light":"/images/wallhaven-wqery6-light.webp","dark":"/images/wallhaven-wqery6-dark.webp"},"title":"O ever youthful, O ever weeping!","subtitle":{"text":[],"hitokoto":{"enable":false,"api":"https://v1.hitokoto.cn"},"typing_speed":100,"backing_speed":80,"starting_delay":500,"backing_delay":1500,"loop":true,"smart_backspace":true},"text_color":{"light":"#fff","dark":"#d1d1b6"},"text_style":{"title_size":"2.8rem","subtitle_size":"1.5rem","line_height":1.2},"custom_font":{"enable":false,"family":null,"url":null},"social_links":{"enable":false,"links":{"github":null,"instagram":null,"zhihu":null,"twitter":null,"email":null},"qrs":{"weixin":null}}},"plugins":{"feed":{"enable":false},"aplayer":{"enable":false,"type":"fixed","audios":[{"name":null,"artist":null,"url":null,"cover":null}]},"mermaid":{"enable":false,"version":"9.3.0"}},"version":"2.6.0","navbar":{"auto_hide":false,"color":{"left":"#f78736","right":"#367df7","transparency":35},"links":{"Home":{"path":"/","icon":"fa-regular fa-house"},"Archives":{"path":"/archives","icon":"fa-regular fa-archive"},"Enjoy":{"path":"/enjoy","icon":"fa-regular fa-heartbeat","submenus":{"Movie":"/movie","Image":"/masonry"}},"About":{"icon":"fa-regular fa-user","submenus":{"Me":"/about","Gitee":"https://gitee.com/liyuncc","Friends":"/friends"}}},"search":{"enable":false,"preload":true}},"page_templates":{"friends_column":2,"tags_style":"blur"},"home":{"sidebar":{"enable":true,"position":"left","first_item":"menu","announcement":null,"links":{"Archives":{"path":"/archives","icon":"fa-regular fa-archive"},"Tags":{"path":"/tags","icon":"fa-regular fa-tags"}}},"article_date_format":"auto","categories":{"enable":true,"limit":3},"tags":{"enable":true,"limit":3}},"footerStart":"2022/8/17 11:45:14"};
    window.lang_ago = {"second":"%s seconds ago","minute":"%s minutes ago","hour":"%s hours ago","day":"%s days ago","week":"%s weeks ago","month":"%s months ago","year":"%s years ago"};
    window.data = {"masonry":true};
  </script>
    
    <!--- Fontawesome Part-->
    
<link rel="stylesheet" href="/fontawesome/fontawesome.min.css">

    
<link rel="stylesheet" href="/fontawesome/brands.min.css">

    
<link rel="stylesheet" href="/fontawesome/solid.min.css">

    
<link rel="stylesheet" href="/fontawesome/regular.min.css">

    
    
    
    
<!-- hexo injector head_end start -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-math@4.0.0/dist/style.css">
<!-- hexo injector head_end end --><meta name="generator" content="Hexo 7.0.0"><link rel="alternate" href="/atom.xml" title="YunCong's Blog" type="application/atom+xml">
</head>


<body>
<div class="progress-bar-container">
    

    
        <span class="pjax-progress-bar"></span>
<!--        <span class="swup-progress-icon">-->
<!--            <i class="fa-solid fa-circle-notch fa-spin"></i>-->
<!--        </span>-->
    
</div>


<main class="page-container" id="swup">

    

    <div class="main-content-container">


        <div class="main-content-header">
            <header class="navbar-container">

    <div class="navbar-content">
        <div class="left">
            
            <a class="logo-title" href="/">
                
                YunCong&#39;s Blog
                
            </a>
        </div>

        <div class="right">
            <!-- PC -->
            <div class="desktop">
                <ul class="navbar-list">
                    
                        
                            

                            <li class="navbar-item">
                                <!-- Menu -->
                                <a class=""
                                   href="/"
                                        >
                                    <i class="fa-regular fa-house fa-fw"></i>
                                    HOME
                                    
                                </a>

                                <!-- Submenu -->
                                
                            </li>
                    
                        
                            

                            <li class="navbar-item">
                                <!-- Menu -->
                                <a class=""
                                   href="/archives"
                                        >
                                    <i class="fa-regular fa-archive fa-fw"></i>
                                    ARCHIVES
                                    
                                </a>

                                <!-- Submenu -->
                                
                            </li>
                    
                        
                            

                            <li class="navbar-item">
                                <!-- Menu -->
                                <a class="has-dropdown"
                                   href="#"
                                        onClick=&#34;return false;&#34;>
                                    <i class="fa-regular fa-heartbeat fa-fw"></i>
                                    ENJOY
                                    <i class="fa-solid fa-chevron-down fa-fw"></i>
                                </a>

                                <!-- Submenu -->
                                
                                    <ul class="sub-menu">
                                        
                                            <li>
                                                <a href="/movie">
                                                    MOVIE
                                                </a>
                                            </li>
                                        
                                            <li>
                                                <a href="/masonry">
                                                    IMAGE
                                                </a>
                                            </li>
                                        
                                    </ul>
                                
                            </li>
                    
                        
                            

                            <li class="navbar-item">
                                <!-- Menu -->
                                <a class="has-dropdown"
                                   href="#"
                                        onClick=&#34;return false;&#34;>
                                    <i class="fa-regular fa-user fa-fw"></i>
                                    ABOUT
                                    <i class="fa-solid fa-chevron-down fa-fw"></i>
                                </a>

                                <!-- Submenu -->
                                
                                    <ul class="sub-menu">
                                        
                                            <li>
                                                <a href="/about">
                                                    ME
                                                </a>
                                            </li>
                                        
                                            <li>
                                                <a target="_blank" rel="noopener" href="https://gitee.com/liyuncc">
                                                    GITEE
                                                </a>
                                            </li>
                                        
                                            <li>
                                                <a href="/friends">
                                                    FRIENDS
                                                </a>
                                            </li>
                                        
                                    </ul>
                                
                            </li>
                    
                    
                </ul>
            </div>
            <!-- Mobile -->
            <div class="mobile">
                
                <div class="icon-item navbar-bar">
                    <div class="navbar-bar-middle"></div>
                </div>
            </div>
        </div>
    </div>

    <!-- Mobile drawer -->
    <div class="navbar-drawer h-screen w-full absolute top-0 left-0 bg-background-color flex flex-col justify-between">
        <ul class="drawer-navbar-list flex flex-col px-4 justify-center items-start">
            
                
                    

                    <li class="drawer-navbar-item text-base my-1.5 flex flex-col w-full">
                        
                        <a class="py-1.5 px-2 flex flex-row items-center justify-between gap-1 hover:!text-primary active:!text-primary text-2xl font-semibold group border-b border-border-color hover:border-primary w-full "
                           href="/"
                        >
                            <span>
                                HOME
                            </span>
                            
                                <i class="fa-regular fa-house fa-sm fa-fw"></i>
                            
                        </a>
                        

                        
                    </li>
            
                
                    

                    <li class="drawer-navbar-item text-base my-1.5 flex flex-col w-full">
                        
                        <a class="py-1.5 px-2 flex flex-row items-center justify-between gap-1 hover:!text-primary active:!text-primary text-2xl font-semibold group border-b border-border-color hover:border-primary w-full "
                           href="/archives"
                        >
                            <span>
                                ARCHIVES
                            </span>
                            
                                <i class="fa-regular fa-archive fa-sm fa-fw"></i>
                            
                        </a>
                        

                        
                    </li>
            
                
                    

                    <li class="drawer-navbar-item-sub text-base my-1.5 flex flex-col w-full">
                        
                        <div class="py-1.5 px-2 flex flex-row items-center justify-between gap-1 hover:!text-primary active:!text-primary cursor-pointer text-2xl font-semibold group border-b border-border-color hover:border-primary w-full "
                             navbar-data-toggle="submenu-Enjoy"
                        >
                            <span>
                                ENJOY
                            </span>
                            
                                <i class="fa-solid fa-chevron-right fa-sm fa-fw transition-all"></i>
                            
                        </div>
                        

                        
                            <div class="flex-col items-start px-2 py-2 hidden" data-target="submenu-Enjoy">
                                
                                    <div class="drawer-navbar-item text-base flex flex-col justify-center items-start hover:underline active:underline hover:underline-offset-1 rounded-3xl">
                                        <a class=" text-third-text-color text-xl"
                                           href="/movie">MOVIE</a>
                                    </div>
                                
                                    <div class="drawer-navbar-item text-base flex flex-col justify-center items-start hover:underline active:underline hover:underline-offset-1 rounded-3xl">
                                        <a class=" text-third-text-color text-xl"
                                           href="/masonry">IMAGE</a>
                                    </div>
                                
                            </div>
                        
                    </li>
            
                
                    

                    <li class="drawer-navbar-item-sub text-base my-1.5 flex flex-col w-full">
                        
                        <div class="py-1.5 px-2 flex flex-row items-center justify-between gap-1 hover:!text-primary active:!text-primary cursor-pointer text-2xl font-semibold group border-b border-border-color hover:border-primary w-full "
                             navbar-data-toggle="submenu-About"
                        >
                            <span>
                                ABOUT
                            </span>
                            
                                <i class="fa-solid fa-chevron-right fa-sm fa-fw transition-all"></i>
                            
                        </div>
                        

                        
                            <div class="flex-col items-start px-2 py-2 hidden" data-target="submenu-About">
                                
                                    <div class="drawer-navbar-item text-base flex flex-col justify-center items-start hover:underline active:underline hover:underline-offset-1 rounded-3xl">
                                        <a class=" text-third-text-color text-xl"
                                           href="/about">ME</a>
                                    </div>
                                
                                    <div class="drawer-navbar-item text-base flex flex-col justify-center items-start hover:underline active:underline hover:underline-offset-1 rounded-3xl">
                                        <a class=" text-third-text-color text-xl"
                                           target="_blank" rel="noopener" href="https://gitee.com/liyuncc">GITEE</a>
                                    </div>
                                
                                    <div class="drawer-navbar-item text-base flex flex-col justify-center items-start hover:underline active:underline hover:underline-offset-1 rounded-3xl">
                                        <a class=" text-third-text-color text-xl"
                                           href="/friends">FRIENDS</a>
                                    </div>
                                
                            </div>
                        
                    </li>
            
        </ul>

        <div class="statistics flex justify-around my-2.5">
    <a class="item tag-count-item flex flex-col justify-center items-center w-20" href="/tags">
        <div class="number text-2xl sm:text-xl text-second-text-color font-semibold">3</div>
        <div class="label text-third-text-color text-sm">Tags</div>
    </a>
    <a class="item tag-count-item flex flex-col justify-center items-center w-20" href="/categories">
        <div class="number text-2xl sm:text-xl text-second-text-color font-semibold">0</div>
        <div class="label text-third-text-color text-sm">Categories</div>
    </a>
    <a class="item tag-count-item flex flex-col justify-center items-center w-20" href="/archives">
        <div class="number text-2xl sm:text-xl text-second-text-color font-semibold">5</div>
        <div class="label text-third-text-color text-sm">Posts</div>
    </a>
</div>
    </div>

    <div class="window-mask"></div>

</header>


        </div>

        <div class="main-content-body">

            

            <div class="main-content">

                
                    <div class="post-page-container flex relative justify-between box-border w-full h-full">
    <div class="article-content-container">

        <div class="article-title relative w-full">
            
                <div class="w-full flex items-center pt-6 justify-start">
                    <h1 class="article-title-regular text-second-text-color text-4xl md:text-6xl font-bold px-2 sm:px-6 md:px-8 py-3">数据校验码</h1>
                </div>
            
            </div>

        
            <div class="article-header flex flex-row gap-2 items-center px-2 sm:px-6 md:px-8">
                <div class="avatar w-[46px] h-[46px] flex-shrink-0 rounded-medium border border-border-color p-[1px]">
                    <img src="/images/redefine-avatar.svg">
                </div>
                <div class="info flex flex-col justify-between">
                    <div class="author flex items-center">
                        <span class="name text-default-text-color text-lg font-semibold">liyuncong</span>
                        
                            <span class="author-label ml-1.5 text-xs px-2 py-0.5 rounded-small text-third-text-color border border-shadow-color-1">Lv1</span>
                        
                    </div>
                    <div class="meta-info">
                        <div class="article-meta-info">
    <span class="article-date article-meta-item">
        <i class="fa-regular fa-pen-fancy"></i>&nbsp;
        <span class="desktop">2024-01-09 17:25:32</span>
        <span class="mobile">2024-01-09 17:25:32</span>
        <span class="hover-info">Created</span>
    </span>
    
        <span class="article-date article-meta-item">
            <i class="fa-regular fa-wrench"></i>&nbsp;
            <span class="desktop">2024-01-10 10:47:40</span>
            <span class="mobile">2024-01-10 10:47:40</span>
            <span class="hover-info">Updated</span>
        </span>
    

    
    

    
    
    
    
        <span class="article-pv article-meta-item">
            <i class="fa-regular fa-eye"></i>&nbsp;<span id="busuanzi_value_page_pv"></span>
        </span>
    
</div>

                    </div>
                </div>
            </div>
        

        


        <div class="article-content markdown-body px-2 sm:px-6 md:px-8 pb-8">
            <h2 id="零、基本原理"><a href="#零、基本原理" class="headerlink" title="零、基本原理"></a>零、基本原理</h2><h3 id="1、数据校验的基本原理"><a href="#1、数据校验的基本原理" class="headerlink" title="1、数据校验的基本原理"></a>1、数据校验的基本原理</h3><blockquote>
<p>数据校验的基本原理是在正常编码中加入一些冗余位，即在正常编码组中加入一些非法编码，当合法数据编码出现某些错误时，就成为非法编码，因此就可以通过检测编码是否合法来达到自动发现、定位乃至改正错误的目的。</p>
</blockquote>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/images/data-check-code-principle.png"
                      alt="data-check-code-principle.png"
                ></p>
<h3 id="2、码距"><a href="#2、码距" class="headerlink" title="2、码距"></a>2、码距</h3><blockquote>
<p>通常把一组编码中任何两个编码之间代码不同的位数称为这两个编码的距离。而码距是指在一组编码中任何两个编码之间最小的距离。</p>
</blockquote>
<p><strong>解释：</strong></p>
<p>同一编码中，任意两个合法编码之间不同二进制数位数的最小值；</p>
<p>例如：</p>
<div class="highlight-container" data-rel="Text"><figure class="iseeu highlight text"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">0011 与 0001 的码距为 1；</span><br><span class="line">0000、0011、0101、0110、1001、1010、1100、1111等编码的码距为 2；</span><br></pre></td></tr></table></figure></div>

<p><font color="red"><strong>校验码中增加冗余项的目的就是为了增大码距。</strong></font></p>
<h3 id="3、码距与检错纠错能力的关系"><a href="#3、码距与检错纠错能力的关系" class="headerlink" title="3、码距与检错纠错能力的关系"></a>3、码距与检错纠错能力的关系</h3><blockquote>
<p>一般来说，合理地增加校验位、增大码距，就能提高校验码发现错误的能力。</p>
</blockquote>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/images/data-check-principle-code-distances-and-correction-capability.png"
                      alt="data-check-principle-code-distances-and-correction-capability.png"
                ></p>
<h2 id="一、奇偶校验码-Parity-Check"><a href="#一、奇偶校验码-Parity-Check" class="headerlink" title="一、奇偶校验码(Parity Check)"></a>一、奇偶校验码(Parity Check)</h2><h3 id="1、定义"><a href="#1、定义" class="headerlink" title="1、定义"></a>1、定义</h3><p>用来检测数据传输过程中是否发生错误，是众多校验码中最为简单的一种。</p>
<p>奇偶校验码有两种校验方式：</p>
<ul>
<li>奇校验(Odd)：使n+1位的奇偶校验码中1的个数为奇数（原始码流 + 校验位 &#x3D; 总共有<strong>奇数</strong>个 <strong>1</strong>）</li>
<li>偶校验(Even)：使n+1位的奇偶校验码中1的个数为偶数（原始码流 + 校验位 &#x3D; 总共有<strong>偶数</strong>个 <strong>1</strong>）</li>
</ul>
<h3 id="2、算法"><a href="#2、算法" class="headerlink" title="2、算法"></a>2、算法</h3><p>奇偶校验是在原始码流后面，加上校验位。它的校验位只有一位，要么是0，要么是1；并且它的校验码还可以放在码流的前面。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/images/data-check-code-parity-check.png"
                      alt="data-check-code-parity-check.png"
                ></p>
<p><strong>例如：</strong></p>
<table>
<thead>
<tr>
<th>原始码</th>
<th>奇校验</th>
<th>偶校验</th>
</tr>
</thead>
<tbody><tr>
<td>1011000</td>
<td>10110000</td>
<td>10110001</td>
</tr>
<tr>
<td>1001101</td>
<td>10011011</td>
<td>10011010</td>
</tr>
</tbody></table>
<h3 id="3、应用举例"><a href="#3、应用举例" class="headerlink" title="3、应用举例"></a>3、应用举例</h3><p>奇偶校验码一个最为常见的应用场合就是ASCII码。</p>
<p>ASCII码占用一个字节，低7位是有效位，最高位做奇偶校验位；</p>
<p><strong>例如：ASCII码 大写字母A</strong></p>
<blockquote>
<p>二进制：010000001</p>
<p>奇校验：110000001</p>
<p>偶校验：010000001</p>
</blockquote>
<h3 id="4、错误检测能力"><a href="#4、错误检测能力" class="headerlink" title="4、错误检测能力"></a>4、错误检测能力</h3><p><font color="red"><strong>只能检测出奇数个错误。</strong></font></p>
<p><strong>例如：ASCII码 大写字母 A</strong></p>
<blockquote>
<p>奇校验：正确码流 110000001</p>
<p>错1位：1100000<strong>1</strong>1 偶数个1，能检测出来 （右往左，第二位错误）</p>
<p>错2位：1100000<strong>10</strong> 奇数个1，检测不出来 （右往左，第一、第二位错误）</p>
<p>错3位：110000<strong>110</strong> 偶数个1，能检测出来 （右往左，第一、第二、第三位错误）</p>
</blockquote>
<blockquote>
<p>偶校验：正确码流 010000001</p>
<p>错1位：01000000<strong>0</strong> 奇数个1，能检测出来 （右往左，第一位错误）</p>
<p>错2位：0100000<strong>10</strong> 偶数个1，检测不出来 （右往左，第一、第二位错误）</p>
<p>错3位：010000<strong>110</strong> 奇数个1，能检测出来 （右往左，第一、第二、第三位错误）</p>
</blockquote>
<h3 id="5、特征"><a href="#5、特征" class="headerlink" title="5、特征"></a>5、特征</h3><p>奇校验一个重要的特征是产生不了全0代码，所以在实际操作过程中选择的时候要考虑到这一点。</p>
<h2 id="二、CRC循环冗余校验码（Cyclic-Redundancy-Check）"><a href="#二、CRC循环冗余校验码（Cyclic-Redundancy-Check）" class="headerlink" title="二、CRC循环冗余校验码（Cyclic Redundancy Check）"></a>二、CRC循环冗余校验码（Cyclic Redundancy Check）</h2><h3 id="1、定义-1"><a href="#1、定义-1" class="headerlink" title="1、定义"></a>1、定义</h3><blockquote>
<p>是一种根据网上数据包或计算机文件等数据产生简短固定位数校验码的一种散列函数，主要用来检测或校验数据传输或者存储后可能出现的错误。</p>
</blockquote>
<p>CRC的目的是保证数据的完整性，其方法是在发送数据的后面再增加多余的若干位数据，接收方使用同样的CRC计算方法，检查接收到的数据CRC是否为0：</p>
<ul>
<li>为0：表示数据是完整的；</li>
<li>不为0：表示数据不完整&#x2F;错误，（接收方丢弃或要求重发）；</li>
</ul>
<p>发送码串的时候，在原始码串后面加上CRC。CRC一般有8bit，16bit和32bit。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/images/data-check-code-crc.png"
                      alt="data-check-code-crc.png"
                ></p>
<h3 id="2、算法-1"><a href="#2、算法-1" class="headerlink" title="2、算法"></a>2、算法</h3><p>CRC采用的策略是用除法求余数。</p>
<p>不同于十进制的除法运算，CRC用的是二进制的除法运算，二进制的除法运算，属于模二运算，模二运算的特点是：没有进位。</p>
<h4 id="2-1、模二运算"><a href="#2-1、模二运算" class="headerlink" title="2.1、模二运算"></a>2.1、模二运算</h4><p><strong>模二加法：（可理解为异或运算——相同为0，不同为1）</strong></p>
<blockquote>
<p>0 + 0 &#x3D; 0</p>
<p>0 + 1 &#x3D; 1</p>
<p>1 + 1 &#x3D; 0 （没有进位）</p>
</blockquote>
<p><strong>模二加法：（可理解为异或运算——相同为0，不同为1）</strong></p>
<blockquote>
<p>0 - 0 &#x3D; 0</p>
<p>0 - 1 &#x3D; 1 （没有借位）</p>
<p>1 - 1 &#x3D; 0</p>
</blockquote>
<p><strong>模二乘法：（可理解为与运算——11得1，其余为0）</strong></p>
<blockquote>
<p>0 * 0 &#x3D; 0</p>
<p>0 * 1 &#x3D; 0</p>
<p>1 * 1 &#x3D; 1</p>
</blockquote>
<p><strong>模二乘法：（模二乘法的逆运算）</strong></p>
<blockquote>
<p>0 &#x2F; 1 &#x3D; 1</p>
<p>1 &#x2F; 1 &#x3D; 0</p>
</blockquote>
<h4 id="2-2、CRC处理过程"><a href="#2-2、CRC处理过程" class="headerlink" title="2.2、CRC处理过程"></a>2.2、CRC处理过程</h4><p><strong>发送端计算CRC的过程</strong></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/images/data-check-code-crc-calculate-sender.png"
                      alt="data-check-code-crc-calculate-sender.png"
                ></p>
<p><strong>接收端校验CRC的过程</strong></p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/images/data-check-code-crc-calculate-receiver.png"
                      alt="data-check-code-crc-calculate-receiver.png"
                ></p>
<p><strong><font color=blue>注意：原始串码补0个数和多项生成式的关联：</font></strong></p>
<p>看发送方和接收方约定的<strong>生成多项式</strong>的码有几位，<strong>补零个数是多项式码位数减一</strong>；</p>
<h2 id="三、海明校验码（Hamming-Code）"><a href="#三、海明校验码（Hamming-Code）" class="headerlink" title="三、海明校验码（Hamming Code）"></a>三、海明校验码（Hamming Code）</h2><h3 id="1、定义-2"><a href="#1、定义-2" class="headerlink" title="1、定义"></a>1、定义</h3><p>由Richard Hamming于1950年提出、还被广泛采用的一种很有效的校验方法，是只要增加少数几个校验位，就能检测出二位同时出错、亦能检测出一位出错并能自动恢复该出错位的正确值的有效手段，后者被称为自动纠错。</p>
<p><strong>基本原理：</strong></p>
<p>在k个数据位之外加上r个校验位，从而形成一个k+r位的新的码字，使新的码字的码距比较均匀地拉大。把数据的每一个二进制位分配在几个不同的偶校验位的组合中，当某一位出错后，就会引起相关的几个校验位的值发生变化，这不但可以发现出错，还能指出是哪一位出错，为进一步自动纠错提供了依据。</p>
<p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/images/data-check-code-hamming-code.png"
                      alt="data-check-code-hamming-code.png"
                ></p>
<p>如果出错代码的位置能够确定，将出错位的内容取反，就能够自动纠正错误，因此满足式（2-14）的海明校验码能够检测出一位错误并且能自动纠正一位错误。</p>
<h3 id="2、算法-2"><a href="#2、算法-2" class="headerlink" title="2、算法"></a>2、算法</h3><p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/images/data-check-code-hamming-code-structure.png"
                      alt="data-check-code-hamming-code-structure.png"
                ><br>$$k + r &lt;&#x3D; 2^r -1$$</p>
<p><strong>2.1 设 k + r 位海明码从左到右一次为第1，2，3，……，k+r位，r位校验位记为Pi（i&#x3D;1，2，3，……，r），分别位于k+r位海明编码的第$2^{i-1}$（i&#x3D;1，2，3，……，r）位上，其余位依次放置被校验的数据位；</strong></p>
<p><strong>2.2 例如：（7，4）海明校验码中校验位和被校验信息位的排列如下：</strong></p>
<table>
<thead>
<tr>
<th>海明校验码位号Hj</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th>7</th>
<th>8</th>
<th>9</th>
<th>10</th>
<th>11</th>
</tr>
</thead>
<tbody><tr>
<td>P和b的分布</td>
<td>P1</td>
<td>P2</td>
<td>b1</td>
<td>P3</td>
<td>b2</td>
<td>b3</td>
<td>b4</td>
<td>P4</td>
<td>b5</td>
<td>b6</td>
<td>b7</td>
</tr>
</tbody></table>
<p>说明：P1位置 &#x3D; $2^{1-1}$ &#x3D; 1，P2位置 &#x3D; $2^{2-1}$ &#x3D; 2，P3位置 &#x3D; $2^{3-1}$ &#x3D; 4，P4位置 &#x3D; $2^{4-1}$ &#x3D; 8，b的位置依次排入；</p>
<p><strong>2.3 Hj位的数据被编号小于j的若干个海明位号之和等于j的校验位所校验，如：</strong></p>
<table>
<thead>
<tr>
<th>海明校验码位号Hj</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th>7</th>
<th>8</th>
<th>9</th>
<th>10</th>
<th>11</th>
</tr>
</thead>
<tbody><tr>
<td>海明校验位</td>
<td>1</td>
<td>2</td>
<td>1，2</td>
<td>4</td>
<td>1，4</td>
<td>2，4</td>
<td>1，2，4</td>
<td>8</td>
<td>1，8</td>
<td>2，8</td>
<td>1，2，8</td>
</tr>
<tr>
<td>P和b的分布</td>
<td>P1</td>
<td>P2</td>
<td>b1</td>
<td>P3</td>
<td>b2</td>
<td>b3</td>
<td>b4</td>
<td>P4</td>
<td>b5</td>
<td>b6</td>
<td>b7</td>
</tr>
</tbody></table>
<p>由此可采用偶校验计算出P1～P4四个校验位的值：</p>
<div class="highlight-container" data-rel="Text"><figure class="iseeu highlight text"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">P1 = b1 b2 b4 b5 b7 （P1校验位被b1、b2、b4、b5、b6用到；然后计算当前编码的奇偶校验位）</span><br><span class="line">P2 = b1 b3 b4 b6 b7 （同理）</span><br><span class="line">P3 = b2 b3 b4 （同理）</span><br><span class="line">P4 = b5 b6 b7 （同理）</span><br></pre></td></tr></table></figure></div>

<p><strong>2.4 设置指错字G4，G3，G2，G1，依旧采用奇偶校验计算：</strong></p>
<div class="highlight-container" data-rel="Text"><figure class="iseeu highlight text"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">G4 = P4 b5 b6 b7</span><br><span class="line">G3 = P3 b2 b3 b4</span><br><span class="line">G2 = P2 b1 b3 b4 b6 b7</span><br><span class="line">G1 = P1 b1 b2 b4 b5 b7</span><br></pre></td></tr></table></figure></div>

<p>G4 G3 G2 G1为0则表示无错误，反之指出出错位的海明码位号；</p>
<p><strong>例如：</strong></p>
<p>被传送的信息位为：b1 b2 b3 b4 b5 b6 b7 &#x3D; 1 0 1 1 0 0 0，采用偶校验；</p>
<table>
<thead>
<tr>
<th>海明校验码位号Hj</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
<th>7</th>
<th>8</th>
<th>9</th>
<th>10</th>
<th>11</th>
</tr>
</thead>
<tbody><tr>
<td>海明校验位</td>
<td>1</td>
<td>2</td>
<td>1，2</td>
<td>4</td>
<td>1，4</td>
<td>2，4</td>
<td>1，2，4</td>
<td>8</td>
<td>1，8</td>
<td>2，8</td>
<td>1，2，8</td>
</tr>
<tr>
<td>P和b的分布</td>
<td>P1</td>
<td>P2</td>
<td>b1</td>
<td>P3</td>
<td>b2</td>
<td>b3</td>
<td>b4</td>
<td>P4</td>
<td>b5</td>
<td>b6</td>
<td>b7</td>
</tr>
</tbody></table>
<p>计算P1，P2，P3，P4：</p>
<div class="highlight-container" data-rel="Text"><figure class="iseeu highlight text"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">P1 = b1 b2 b4 b5 b7 = 1 0 1 0 0 = 0</span><br><span class="line">P2 = b1 b3 b4 b6 b7 = 1 1 1 0 0 = 1</span><br><span class="line">P3 = b2 b3 b4 = 0 1 1 = 0 1 1 = 0</span><br><span class="line">P4 = b5 b6 b7 = 0 0 0 = 0 0 0 = 0</span><br></pre></td></tr></table></figure></div>

<p>得到的海明编码为：0 1 1 0 0 1 1 0 0 0 0</p>
<h3 id="3、校验方式"><a href="#3、校验方式" class="headerlink" title="3、校验方式"></a>3、校验方式</h3><p><img  
                     lazyload
                     src="/images/loading.svg"
                     data-src="/images/data-check-code-hamming-code-check-mode.png"
                      alt="data-check-code-hamming-code-check-mode.png"
                ></p>
<p>海明编码的检错需要根据“指错字”的结果进行判断：若“指错字”全为0，则表示信息无误；若“指错字”不全为0，则表示接收到的信息出错，并且“指错字”对应的十进制数就是出错位的位号。</p>
<p><strong>例如：</strong></p>
<p>被传送的信息位为：b1 b2 b3 b4 b5 b6 b7 &#x3D; 1 0 1 1 0 0 0，采用偶校验；</p>
<p>当传输无错时：H &#x3D; 0 1 1 0 0 1 1 0 0 0 0</p>
<p>计算指错字：</p>
<div class="highlight-container" data-rel="Text"><figure class="iseeu highlight text"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">G4 = P4 b5 b6 b7 = 0 0 0 0 = 0</span><br><span class="line">G3 = P3 b2 b3 b4 = 0 0 1 1 = 0</span><br><span class="line">G2 = P2 b1 b3 b4 b6 b7 = 1 1 1 1 0 0 = 0</span><br><span class="line">G1 = P1 b1 b2 b4 b5 b7 = 0 1 0 1 0 0 = 0</span><br></pre></td></tr></table></figure></div>

<p>G4 G3 G2 G1 &#x3D; 0 0 0 0，表明无错；</p>
<p>当传输错一位时：H &#x3D; 0 1 1 0 0 1 1 0 0 0 <font color="red">1</font></p>
<p>计算指错字：</p>
<div class="highlight-container" data-rel="Text"><figure class="iseeu highlight text"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">G4 = P4 b5 b6 b7 = 0 0 0 1 = 1</span><br><span class="line">G3 = P3 b2 b3 b4 = 0 0 1 1 = 0</span><br><span class="line">G2 = P2 b1 b3 b4 b6 b7 = 1 1 1 1 0 1 = 1</span><br><span class="line">G1 = P1 b1 b2 b4 b5 b7 = 0 1 0 1 0 1 = 1</span><br></pre></td></tr></table></figure></div>

<p>G4 G3 G2 G1 &#x3D; 1 0 1 1，表明H11（$2^3 + 2^1 + 2^0$）位出错；</p>
<p><font color="red"><strong>注意！指错字能够正确指示出错位所在位置的前提是代码中只能有一个错误。如果代码中存在多个错误，就可能查不出来。所以海明校验码只有在代码中只存在一个错误的前提下，才能实现纠错。</strong></font></p>
<br/>

<hr>
<p><strong>参考链接：</strong></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/26509678" >秒懂 奇偶校验码 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/396165368" >史上解释CRC最清楚的文章 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/26469035" >两幅图学会CRC <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://baike.baidu.com/item/%E6%B5%B7%E6%98%8E%E6%A0%A1%E9%AA%8C%E7%A0%81" >海明校验码 - 百度百科 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/147536255" >数据校验码 - 1.基本原理 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>
<p><a class="link"   target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/147661538" >数据校验码 - 4.海明校验 <i class="fa-regular fa-arrow-up-right-from-square fa-sm"></i></a></p>

        </div>

        
            <div class="post-copyright-info w-full my-8 px-2 sm:px-6 md:px-8">
                <div class="article-copyright-info-container">
    <ul>
        <li><strong>Title:</strong> 数据校验码</li>
        <li><strong>Author:</strong> liyuncong</li>
        <li><strong>Created at
                :</strong> 2024-01-09 17:25:32</li>
        
            <li>
                <strong>Updated at
                    :</strong> 2024-01-10 10:47:40
            </li>
        
        <li>
            <strong>Link:</strong> https://liyuncc.gitee.io/2024/01/09/data-check-code/
        </li>
        <li>
            <strong>
                License:
            </strong>
            

            
                This work is licensed under <a class="license" target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0">CC BY-NC-SA 4.0</a>.
            
        </li>
    </ul>
</div>

            </div>
        

        

        

        
            <div class="article-nav my-8 flex justify-between items-center px-2 sm:px-6 md:px-8">
                
                
                    <div class="article-next border-border-color shadow-redefine-flat shadow-shadow-color-2 rounded-medium px-4 py-2 hover:shadow-redefine-flat-hover hover:shadow-shadow-color-2">
                        <a class="next"
                        rel="next"
                        href="/2024/01/03/data-representation/"
                        >
                            <span class="title flex justify-center items-center">
                                <span class="post-nav-title-item">数据的表示</span>
                                <span class="post-nav-item">Next posts</span>
                            </span>
                            <span class="right arrow-icon flex justify-center items-center">
                                <i class="fa-solid fa-chevron-right"></i>
                            </span>
                        </a>
                    </div>
                
            </div>
        


        
            <div class="comment-container px-2 sm:px-6 md:px-8 pb-8">
                <div class="comments-container mt-10 w-full ">
    <div id="comment-anchor" class="w-full h-2.5"></div>
    <div class="comment-area-title w-full my-1.5 md:my-2.5 text-xl md:text-3xl font-bold">
        Comments
    </div>
    

        
            
    <div id="waline"></div>
    <script type="module" data-swup-reload-script>
      import { init } from '/js/libs/waline.mjs';

      function loadWaline() {
        init({
          el: '#waline',
          serverURL: 'https://example.example.com',
          lang: 'zh-CN',
          dark: 'body[class~="dark-mode"]',
          requiredMeta: ['nick', 'mail'],
          emoji: [],
          recaptchaV3Key: "wasd",
          
        });
      }

      if (typeof swup !== 'undefined') {
        loadWaline();
      } else {
        window.addEventListener('DOMContentLoaded', loadWaline);
      }
    </script>



        
    
</div>

            </div>
        
    </div>

    
        <div class="toc-content-container">
            <div class="post-toc-wrap">
    <div class="post-toc">
        <div class="toc-title">On this page</div>
        <div class="page-title">数据校验码</div>
        <ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%9B%B6%E3%80%81%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86"><span class="nav-text">零、基本原理</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E6%95%B0%E6%8D%AE%E6%A0%A1%E9%AA%8C%E7%9A%84%E5%9F%BA%E6%9C%AC%E5%8E%9F%E7%90%86"><span class="nav-text">1、数据校验的基本原理</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E7%A0%81%E8%B7%9D"><span class="nav-text">2、码距</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81%E7%A0%81%E8%B7%9D%E4%B8%8E%E6%A3%80%E9%94%99%E7%BA%A0%E9%94%99%E8%83%BD%E5%8A%9B%E7%9A%84%E5%85%B3%E7%B3%BB"><span class="nav-text">3、码距与检错纠错能力的关系</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E5%A5%87%E5%81%B6%E6%A0%A1%E9%AA%8C%E7%A0%81-Parity-Check"><span class="nav-text">一、奇偶校验码(Parity Check)</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E5%AE%9A%E4%B9%89"><span class="nav-text">1、定义</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E7%AE%97%E6%B3%95"><span class="nav-text">2、算法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81%E5%BA%94%E7%94%A8%E4%B8%BE%E4%BE%8B"><span class="nav-text">3、应用举例</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4%E3%80%81%E9%94%99%E8%AF%AF%E6%A3%80%E6%B5%8B%E8%83%BD%E5%8A%9B"><span class="nav-text">4、错误检测能力</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5%E3%80%81%E7%89%B9%E5%BE%81"><span class="nav-text">5、特征</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%BA%8C%E3%80%81CRC%E5%BE%AA%E7%8E%AF%E5%86%97%E4%BD%99%E6%A0%A1%E9%AA%8C%E7%A0%81%EF%BC%88Cyclic-Redundancy-Check%EF%BC%89"><span class="nav-text">二、CRC循环冗余校验码（Cyclic Redundancy Check）</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E5%AE%9A%E4%B9%89-1"><span class="nav-text">1、定义</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E7%AE%97%E6%B3%95-1"><span class="nav-text">2、算法</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E6%B5%B7%E6%98%8E%E6%A0%A1%E9%AA%8C%E7%A0%81%EF%BC%88Hamming-Code%EF%BC%89"><span class="nav-text">三、海明校验码（Hamming Code）</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1%E3%80%81%E5%AE%9A%E4%B9%89-2"><span class="nav-text">1、定义</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2%E3%80%81%E7%AE%97%E6%B3%95-2"><span class="nav-text">2、算法</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3%E3%80%81%E6%A0%A1%E9%AA%8C%E6%96%B9%E5%BC%8F"><span class="nav-text">3、校验方式</span></a></li></ol></li></ol>

    </div>
</div>
        </div>
    
</div>



                

            </div>

            

        </div>

        <div class="main-content-footer">
            <footer class="footer mt-5 py-5 h-auto text-base text-third-text-color relative border-t-2 border-t-border-color">
    <div class="info-container py-3 text-center">
        
        <div class="text-center">
            &copy;
            
              <span>2022</span>
              -
            
            2024&nbsp;&nbsp;<i class="fa-solid fa-heart fa-beat" style="--fa-animation-duration: 0.5s; color: #f54545"></i>&nbsp;&nbsp;<a href="/">liyuncong</a>
        </div>
        
            <script data-swup-reload-script src="https://cn.vercount.one/js"></script>
            <div class="relative text-center lg:absolute lg:right-[20px] lg:top-1/2 lg:-translate-y-1/2 lg:text-right">
                
                    <span id="busuanzi_container_site_uv" class="lg:!block">
                        <span class="text-sm">VISITOR COUNT</span>
                        <span id="busuanzi_value_site_uv"></span>
                    </span>
                
                
                    <span id="busuanzi_container_site_pv" class="lg:!block">
                        <span class="text-sm">TOTAL PAGE VIEWS</span>
                        <span id="busuanzi_value_site_pv"></span>
                    </span>
                
            </div>
        
        <div class="relative text-center lg:absolute lg:left-[20px] lg:top-1/2 lg:-translate-y-1/2 lg:text-left">
            <span class="lg:block text-sm">POWERED BY <?xml version="1.0" encoding="utf-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg class="relative top-[2px] inline-block align-baseline" version="1.1" id="圖層_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="1rem" height="1rem" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve"><path fill="#0E83CD" d="M256.4,25.8l-200,115.5L56,371.5l199.6,114.7l200-115.5l0.4-230.2L256.4,25.8z M349,354.6l-18.4,10.7l-18.6-11V275H200v79.6l-18.4,10.7l-18.6-11v-197l18.5-10.6l18.5,10.8V237h112v-79.6l18.5-10.6l18.5,10.8V354.6z"/></svg><a target="_blank" class="text-base" href="https://hexo.io">Hexo</a></span>
            <span class="text-sm lg:block">THEME&nbsp;<a class="text-base" target="_blank" href="https://github.com/EvanNotFound/hexo-theme-redefine">Redefine v2.6.0</a></span>
        </div>
        
        
            <div>
                Blog up for <span class="odometer" id="runtime_days" ></span> days <span class="odometer" id="runtime_hours"></span> hrs <span class="odometer" id="runtime_minutes"></span> Min <span class="odometer" id="runtime_seconds"></span> Sec
            </div>
        
        
            <script data-swup-reload-script>
                try {
                    function odometer_init() {
                    const elements = document.querySelectorAll('.odometer');
                    elements.forEach(el => {
                        new Odometer({
                            el,
                            format: '( ddd).dd',
                            duration: 200
                        });
                    });
                    }
                    odometer_init();
                } catch (error) {}
            </script>
        
        
        
    </div>  
</footer>
        </div>
    </div>

    
        <div class="post-tools">
            <div class="post-tools-container">
    <ul class="article-tools-list">
        <!-- TOC aside toggle -->
        
            <li class="right-bottom-tools page-aside-toggle">
                <i class="fa-regular fa-outdent"></i>
            </li>
        

        <!-- go comment -->
        
            <li class="go-comment">
                <i class="fa-regular fa-comments"></i>
            </li>
        
    </ul>
</div>

        </div>
    

    <div class="right-side-tools-container">
        <div class="side-tools-container">
    <ul class="hidden-tools-list">
        <li class="right-bottom-tools tool-font-adjust-plus flex justify-center items-center">
            <i class="fa-regular fa-magnifying-glass-plus"></i>
        </li>

        <li class="right-bottom-tools tool-font-adjust-minus flex justify-center items-center">
            <i class="fa-regular fa-magnifying-glass-minus"></i>
        </li>

        <li class="right-bottom-tools tool-dark-light-toggle flex justify-center items-center">
            <i class="fa-regular fa-moon"></i>
        </li>

        <!-- rss -->
        

        

        <li class="right-bottom-tools tool-scroll-to-bottom flex justify-center items-center">
            <i class="fa-regular fa-arrow-down"></i>
        </li>
    </ul>

    <ul class="visible-tools-list">
        <li class="right-bottom-tools toggle-tools-list flex justify-center items-center">
            <i class="fa-regular fa-cog fa-spin"></i>
        </li>
        
            <li class="right-bottom-tools tool-scroll-to-top flex justify-center items-center">
                <i class="arrow-up fas fa-arrow-up"></i>
                <span class="percent"></span>
            </li>
        
        
    </ul>
</div>

    </div>

    <div class="image-viewer-container">
    <img src="">
</div>


    

</main>


    
<script src="/js/libs/Swup.min.js"></script>

<script src="/js/libs/SwupSlideTheme.min.js"></script>

<script src="/js/libs/SwupScriptsPlugin.min.js"></script>

<script src="/js/libs/SwupProgressPlugin.min.js"></script>

<script src="/js/libs/SwupScrollPlugin.min.js"></script>

<script src="/js/libs/SwupPreloadPlugin.min.js"></script>

<script>
    const swup = new Swup({
        plugins: [
            new SwupScriptsPlugin({
                optin: true,
            }),
            new SwupProgressPlugin(),
            new SwupScrollPlugin({
                offset: 80,
            }),
            new SwupSlideTheme({
                mainElement: ".main-content-body",
            }),
            new SwupPreloadPlugin(),
        ],
        containers: ["#swup"],
    });
</script>







<script src="/js/tools/imageViewer.js" type="module"></script>

<script src="/js/utils.js" type="module"></script>

<script src="/js/main.js" type="module"></script>

<script src="/js/layouts/navbarShrink.js" type="module"></script>

<script src="/js/tools/scrollTopBottom.js" type="module"></script>

<script src="/js/tools/lightDarkSwitch.js" type="module"></script>

<script src="/js/layouts/categoryList.js" type="module"></script>





    
<script src="/js/tools/codeBlock.js" type="module"></script>




    
<script src="/js/layouts/lazyload.js" type="module"></script>




    
<script src="/js/tools/runtime.js"></script>

    
<script src="/js/libs/odometer.min.js"></script>

    
<link rel="stylesheet" href="/assets/odometer-theme-minimal.css">




  
<script src="/js/libs/Typed.min.js"></script>

  
<script src="/js/plugins/typed.js" type="module"></script>






    
<script src="/js/libs/minimasonry.min.js"></script>

    
<script src="/js/plugins/masonry.js" type="module"></script>





<div class="post-scripts" data-swup-reload-script>
    
        
<script src="/js/tools/tocToggle.js" type="module"></script>

<script src="/js/layouts/toc.js" type="module"></script>

<script src="/js/plugins/tabs.js" type="module"></script>

    
</div>


</body>
</html>
